package com.peironcely.web.controllers;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.peironcely.services.beans.Valor;
import com.peironcely.services.business.BusinessService;

@Controller
public class RestController {
	
	@Autowired
	private BusinessService businessService;

	public void setBusinessService(BusinessService businessService) {
		this.businessService = businessService;
	}
	
	@RequestMapping(value="/valor/{idValue}", method = RequestMethod.GET)  
	public @ResponseBody Valor getValor(@PathVariable String idValue){
		return businessService.getValor(Integer.parseInt(idValue));
	}
	
	@RequestMapping(value = "/valores", method = RequestMethod.GET)  
	public @ResponseBody List<Valor> listValores(){
		return businessService.listValores();
	}

}
